package top.lilele.adminSystem.web;

import cn.dev33.satoken.stp.StpUtil;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.lilele.adminSystem.entity.AdminFolderFileEntity;
import top.lilele.adminSystem.service.AdminFolderFileService;
import top.lilele.adminSystem.utils.BaseResponse;
import top.lilele.adminSystem.utils.ResponseCodeEnum;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lilele
 */
@RestController
@RequestMapping(value = "folderFile")
public class AdminFolderFileController {

    @Resource
    AdminFolderFileService adminFolderFileService;

    @PostMapping(value = "add")
    public BaseResponse add(@RequestBody @Validated AdminFolderFileEntity adminFolderFileEntity) {
        adminFolderFileEntity.setCreatedId(StpUtil.getLoginIdAsString());
        adminFolderFileService.add(adminFolderFileEntity);
        return BaseResponse.info(ResponseCodeEnum.Success, null);
    }

    @PostMapping(value = "queryFolderFileList")
    public BaseResponse queryFolderFileList() {
        List<AdminFolderFileEntity> list = adminFolderFileService.queryFolderFileList();
        return BaseResponse.info(ResponseCodeEnum.Success, list);
    }
}
